package com.example.firstjavamqtt.controller.log_api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.firstjavamqtt.common.result.Result;
import com.example.firstjavamqtt.common.result.ResultCodeEnum;
import com.example.firstjavamqtt.model.log.InfraredMonitorLog;
import com.example.firstjavamqtt.model.log.LedLog;
import com.example.firstjavamqtt.service.log.InfraredLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/log/infrared")
@Api(tags = "人体检测日志接口")
public class InfraredLogController {

    @Autowired
    InfraredLogService infraredLogService;

    @ApiOperation("根据id删除红外日志")
    @GetMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable int id) {
        infraredLogService.deleteInfraredMonitorLogById(id);
        return Result.ok();
    }

    @ApiOperation("根据deviceId删除红外日志")
    @GetMapping("/deleteByDeviceId/{deviceId}")
    public Result deleteByDeviceId(@PathVariable String deviceId) {
        infraredLogService.deleteInfraredMonitorLogByDeviceId(deviceId);
        return Result.ok();
    }

    @ApiOperation("根据批量ID删除红外日志")
    @GetMapping("/deleteByBatchId/{batchId}")
    public Result deleteByBatchId(@PathVariable ArrayList<Integer> batchId) {
        infraredLogService.deleteInfraredMonitorLogByBatchId(batchId);
        return Result.ok();
    }

    @ApiOperation("获取分页的全部红外日志")
    @GetMapping("/getAll/{pageNum}/{limit}")
    public Result getAllInfraredLog(@PathVariable int pageNum,@PathVariable int limit) {
        Page<InfraredMonitorLog> pageModel = infraredLogService.getAllInfraredLog(pageNum,limit);
        return Result.ok(pageModel);
    }
}
